package com.yanqu.road.entity.activity.unionwar;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.union.UnionBaseInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 商会战-商会详情（门客派遣、银两、锦囊等）
 */
@FieldTypeAnnotation(tableName = "t_u_activity_unionwar_dispatch_detail")
public class UnionWarDispatchDetail extends DataObject {

    /**
     * 活动id
     */
    @FieldTypeAnnotation(select = true, update = true, desc = "活动id")
    private int activityId;
    /**
     * 商会id
     */
    @FieldTypeAnnotation(update = true, desc = "商会id")
    private String unionUid;
    /**
     * 商会信息
     */
    @FieldTypeAnnotation(desc = "商会信息")
    private UnionBaseInfo unionInfo;
    /**
     * 阶段（积分赛、决赛）
     */
    @FieldTypeAnnotation(update = true, desc = "阶段（积分赛、决赛）")
    private int phase;
    /**
     * 场次
     */
    @FieldTypeAnnotation(update = true, desc = "场次")
    private int session;
    /**
     * 门客派遣详情
     */
    @FieldTypeAnnotation(desc = "门客派遣详情")
    private Map<Long, UnionWarUserPatrons> patronsMap = new ConcurrentHashMap<>();
    /**
     * 募捐详情
     */
    @FieldTypeAnnotation(desc = "募捐详情")
    private Map<Long, UnionWarUserSilver> silverMap = new ConcurrentHashMap<>();
    /**
     * 玩家详情
     */
    @FieldTypeAnnotation(desc = "玩家详情")
    private Map<Long, UserBaseInfo> userBaseInfoMap = new ConcurrentHashMap<>();
    /**
     * 对手商会id
     */
    @FieldTypeAnnotation(desc = "对手商会id")
    private String enemyUnionUid;
    /**
     * 对手商会信息
     */
    @FieldTypeAnnotation(desc = "对手商会信息")
    private UnionBaseInfo enemyUnionInfo;
    /**
     * 最后更新时间
     */
    @FieldTypeAnnotation(desc = "最后更新时间")
    private long lastUpdateTime;
    /**
     * 最后上传时间
     */
    @FieldTypeAnnotation(desc = "最后更新时间")
    private long lastPushTime;
    private int winMark;             //胜负标识，0：初始值；1：胜；2：负；3：平手；4：轮空
    /**
     * 战报已读商会成员
     *
     */
    @FieldTypeAnnotation(desc = "战报已读商会成员")
    private List<Long> readUserId = new ArrayList<>();

    @FieldTypeAnnotation(desc = "分组id")
    private int groupId;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if(this.activityId != activityId){
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public String getUnionUid() {
        return unionUid;
    }

    public void setUnionUid(String unionUid) {
        if(!Objects.equals(this.unionUid, unionUid)) {
            this.unionUid = unionUid;
            setUpdateOption();
        }
    }

    public UnionBaseInfo getUnionInfo() {
        return unionInfo;
    }

    public void setUnionInfo(UnionBaseInfo unionInfo) {
        if (!Objects.equals(this.unionInfo, unionInfo)) {
            this.unionInfo = unionInfo;
            setUpdateOption();
        }
    }

    public int getSession() {
        return session;
    }

    public void setSession(int session) {
        if(this.session != session) {
            this.session = session;
            setUpdateOption();
        }
    }

    public int getPhase() {
        return phase;
    }

    public void setPhase(int phase) {
        if(this.phase != phase) {
            this.phase = phase;
            setUpdateOption();
        }
    }

    public Map<Long, UnionWarUserPatrons> getPatronsMap() {
        return patronsMap;
    }

    public void setPatronsMap(Map<Long, UnionWarUserPatrons> patronsMap) {
        this.patronsMap = patronsMap;
        setUpdateOption();
    }

    public void putPatrons(long userId, UnionWarUserPatrons unionWarUserPatrons){
        this.patronsMap.put(userId, unionWarUserPatrons);
        setUpdateOption();
    }

    public Map<Long, UnionWarUserSilver> getSilverMap() {
        return silverMap;
    }

    public void setSilverMap(Map<Long, UnionWarUserSilver> silverMap) {
        this.silverMap = silverMap;
        setUpdateOption();
    }

    public void putSilver(long userId, UnionWarUserSilver unionWarUserSilver){
        this.silverMap.put(userId, unionWarUserSilver);
        setUpdateOption();
    }

    public Map<Long, UserBaseInfo> getUserBaseInfoMap() {
        return userBaseInfoMap;
    }

    public void setUserBaseInfoMap(Map<Long, UserBaseInfo> userBaseInfoMap) {
        this.userBaseInfoMap = userBaseInfoMap;
        setUpdateOption();
    }

    public void putUserBaseInfo(long userId, UserBaseInfo userBaseInfo){
        this.userBaseInfoMap.put(userId, userBaseInfo);
        setUpdateOption();
    }

    public String getEnemyUnionUid() {
        return enemyUnionUid;
    }

    public void setEnemyUnionUid(String enemyUnionUid) {
        if(!Objects.equals(this.enemyUnionUid, enemyUnionUid)) {
            this.enemyUnionUid = enemyUnionUid;
            setUpdateOption();
        }
    }

    public UnionBaseInfo getEnemyUnionInfo() {
        return enemyUnionInfo;
    }

    public void setEnemyUnionInfo(UnionBaseInfo enemyUnionInfo) {
        this.enemyUnionInfo = enemyUnionInfo;
    }

    public long getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(long lastUpdateTime) {
        if(this.lastUpdateTime != lastUpdateTime) {
            this.lastUpdateTime = lastUpdateTime;
            setUpdateOption();
        }
    }

    public long getLastPushTime() {
        return lastPushTime;
    }

    public void setLastPushTime(long lastPushTime) {
        if(this.lastPushTime != lastPushTime) {
            this.lastPushTime = lastPushTime;
            setUpdateOption();
        }
    }

    public int getWinMark() {
        return winMark;
    }

    public void setWinMark(int winMark) {
        if(this.winMark != winMark) {
            this.winMark = winMark;
            setUpdateOption();
        }
    }

    public List<Long> getReadUserId() {
        return readUserId;
    }

    public void setReadUserId(List<Long> readUserId) {
        this.readUserId = readUserId;
        setUpdateOption();
    }

    public void addReadUserId(long userId){
        if(!this.readUserId.contains(userId)){
            this.readUserId.add(userId);
            setUpdateOption();
        }
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if(this.groupId != groupId){
            this.groupId = groupId;
            setUpdateOption();
        }
    }
}
